package com.hqyj.module.InformationQuery.dao;


import com.hqyj.module.InformationQuery.entity.UserInfo;
import com.hqyj.module.clock.pojo.SearchBean;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author ：Cwd
 * @Description：UserInfoMapper
 * @date ：2021/10/8 11:33
 */
@Component
public interface UserInformationMapper {

    /**
     * 个人考勤信息查询
     * @param userName 通过用户名 查找当前用户信息
     * @return 返回当前用户的所有信息
     */
    @Select("select * from user_info where user_name = #{userName}")
    UserInfo getUserInfoByUserName(String userName);

    /**
     * 提供有权限的人员按条件查询，DataTable 实现
     * @param searchBean 展示形式
     * @return 返回所有用户信息
     */
    @Select("<script>"
            + "select * from user_info "
            + "<where> "
            + "<if test='keyword != \"\" and keyword != null'>"
            + " and (dept_name like '%${keyword}%' or "
            + " user_name like '%${keyword}%') "
            + "</if>"
            + "</where>"
            + "<choose>"
            + "<when test='orderBy != \"\" and orderBy != null'>"
            + " order by ${orderBy} ${direction}"
            + "</when>"
            + "<otherwise>"
            + " order by user_id asc"
            + "</otherwise>"
            + "</choose>"
            + "</script>")
    List<UserInfo> getUsersByMyPage(SearchBean searchBean);
}
